package com.demo;

import com.dao.All_player_Mapper;
import com.dao.fruitMapper;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class Test_LoL {


    public static void main(String[] args) throws IOException {
        String resource = "SqlMapConfig.xml";           //绑定主体.xml

        //对SqlMapConfig.xml读取并解析
        InputStream inputStream = Resources.getResourceAsStream(resource);

        //获取会话工厂SqlSessionFactory
        SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(inputStream);

        //SqlSession主要用于对数据库的操作
        SqlSession session =  sessionFactory.openSession();     //获取数据库执行对象

        All_player_Mapper mapper = session.getMapper(All_player_Mapper.class);//接口名.class 获取对象   反射机制，通过接口，执行.xml里sql语句

        //创建Hashmap 存储信息
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("club","SKT");


        List<All_club> all_clubs = mapper.select_player_club(hashMap);
        for (All_club club : all_clubs){

            System.out.println(club.getClub()+"\n");
            System.out.println(club.getAll_player());





        }


        session.commit();     //增删改需要执行事件 查询不用
        session.close();      //关闭
        inputStream.close();


    }


}
